home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / jrpacman.c < prev    next >
C/C++ Source or Header  |  1999-12-07  |  1KB  |  53 lines

  1. /***************************************************************************
  2.  
  3.   machine.c
  4.  
  5.   Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
  6.   I/O ports)
  7.  
  8. ***************************************************************************/
  9.  
  10. #include "driver.h"
  11.  
  12.  
  13. static int speedcheat = 0;    /* a well known hack allows to make JrPac Man run at four times */
  14.                 /* his usual speed. When we start the emulation, we check if the */
  15.                 /* hack can be applied, and set this flag accordingly. */
  16.  
  17.  
  18. void jrpacman_init_machine(void)
  19. {
  20.     unsigned char *RAM = memory_region(REGION_CPU1);
  21.  
  22.  
  23.     /* check if the loaded set of ROMs allows the Pac Man speed hack */
  24.     if (RAM[0x180b] == 0xbe || RAM[0x180b] == 0x01)
  25.         speedcheat = 1;
  26.     else speedcheat = 0;
  27. }
  28.  
  29.  
  30.  
  31. int jrpacman_interrupt(void)
  32. {
  33.     unsigned char *RAM = memory_region(REGION_CPU1);
  34.  
  35.  
  36.     /* speed up cheat */
  37.     if (speedcheat)
  38.     {
  39.         if (readinputport(3) & 1)    /* check status of the fake dip switch */
  40.         {
  41.             /* activate the cheat */
  42.             RAM[0x180b] = 0x01;
  43.         }
  44.         else
  45.         {
  46.             /* remove the cheat */
  47.             RAM[0x180b] = 0xbe;
  48.         }
  49.     }
  50.  
  51.     return interrupt();
  52. }
  53.